import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/home/anchorbaking/text.dart';
import 'package:flutter_douban/model/knowledge_model.dart';

class AnchorView extends StatelessWidget {
  final KnowledgeModel model;

  const AnchorView({Key? key, required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 12, right: 12, top: 15),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '精品 | ${model.name!}',
            style: TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: AppColors.black,
            ),
          ),
          SizedBox(
            height: 8,
          ),
          Row(
            children: [
              _imageAndcount(
                  'recipe_small_view', model.collectsnum!.toString()),
              SizedBox(
                width: 20,
              ),
              _imageAndcount(
                  'collcetionicon_off', model.view_count!.toString()),
            ],
          ),
          SizedBox(
            height: 8,
          ),
          InkWell(
            onTap: () {
              // Navigator.of(context).push(MaterialPageRoute(builder: (_) {
              //   return FutureBuilderDemoPage();
              // }));
            },
            child: ClipRRect(
              child: CachedNetworkImage(
                imageUrl: model.image!,
                fit: BoxFit.cover,
                width: MediaQuery.of(context).size.width,
                height: (MediaQuery.of(context).size.width - 24) / 7 * 4,
              ),
              borderRadius: BorderRadius.circular(4),
            ),
          ),
          SizedBox(
            height: 20,
          ),
          Container(
            height: 1,
            color: AppColors.line,
          )
        ],
      ),
    );
  }

  Widget _imageAndcount(String imgStr, String name) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Image.asset(
          'assets/images/common/${imgStr}.png',
          width: 14,
          height: 14,
          color: Colors.grey,
        ),
        SizedBox(
          width: 5,
        ),
        Text(
          name,
          style: TextStyle(
            fontSize: 12,
            fontWeight: FontWeight.w200,
            color: AppColors.qianTextColor,
          ),
        )
      ],
    );
  }
}
